<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>myNew</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        function myNew() {
            const o = Object.create({});
            const currentConstructor = Array.prototype.shift.call(arguments);
            o.__proto__ = currentConstructor.prototype;
            let res = currentConstructor.apply(o, arguments);
            return typeof res === 'object' ? res : o;
        }
        function Test(name) {
            this.name = name;
        }
        const n1 = myNew(Test, 'eveningwater');
        console.log(n1.name);
    </script>
</body>

</html>